package com.ym.medical.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ym.core.utils.tkmybatis.BaseSVImpl;

import com.ym.medical.dao.DiseaseDeptDao;
import com.ym.medical.domain.entity.DiseaseDeptEntity;
import com.ym.medical.domain.param.DiseaseDeptParam;
import com.ym.medical.service.IBaseDataSV;
import com.ym.medical.service.IDiseaseDeptSV;
import com.ym.medical.service.IStandardDeptSV;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ComputerName:LAPTOP-I6GKDIFQ
 * Author:admin
 * Date: 2019-06-04
 * Time: 17:07:12
 * 服务实现类
 */
@Service
@Transactional( rollbackFor = Exception.class)
public class DiseaseDeptSVImpl extends BaseSVImpl<DiseaseDeptEntity, DiseaseDeptDao> implements IDiseaseDeptSV {


    @Autowired
    private IBaseDataSV iBaseDataSV;

    /**
     * 疾病科室展示
     * @param diseaseDeptModel
     * @param pageNo
     * @param limit
     * @return
     */
    @Override
    public PageInfo<DiseaseDeptEntity> listDiseaseDepat(DiseaseDeptParam diseaseDeptModel, int pageNo, int limit) {
        PageHelper.startPage(pageNo,limit);
        List<DiseaseDeptEntity> diseaseDepts = mapper.listDiseaseDepat(diseaseDeptModel);
        return new PageInfo<>(diseaseDepts);
    }

    /**
     * 疾病科室新增
     * @param diseaseDept
     */
    @Override
    public void insertDiseaseDepat(DiseaseDeptEntity diseaseDept) {
        //根据科室code查询科室信息 设置科室名称
        iBaseDataSV.setStandardDept(diseaseDept);
        mapper.insertSelective(diseaseDept);
    }


    /**
     * 疾病科室修改
     * @param diseaseDept
     */
    @Override
    public void updateDiseaseDepat(DiseaseDeptEntity diseaseDept) {
        //根据科室id查询科室信息 设置科室名称和科室code
        iBaseDataSV.setStandardDept(diseaseDept);
        mapper.updateByPrimaryKeySelective(diseaseDept);
    }
}
